<?php
date_default_timezone_set('PRC');
session_start();
if ($_SESSION["islogin"] !== 'igiveyouthepower') {
    echo "<script language=JavaScript>\r\n";
    echo "alert('请先登录');\r\n";
    echo "location.href='../index.php'\r\n";
    echo "</script>";
}
require_once('../config.php');
$conn = mysqli_connect($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname);


function replacebd($str1, $str2)
{
    $s1 = explode("Brand Name:", $str1);
    $s2 = explode('&lt;br/&gt;', $s1[1]);
    $s3 = str_replace($s2[0], $str2, $str1);
    return $s3;
}

function randomkeys($length)
{
    //$pattern = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ';
    $str = null;
    $strPol = "123456789";//大小写字母以及数字
    $max = strlen($strPol) - 1;

    for ($i = 0; $i < $length; $i++) {
        $str .= $strPol[rand(0, $max)];
    }
    return $str;
}

function EAN13($n)
{
    $n = (string)$n;
    $a = (($n[1] + $n[3] + $n[5] + $n[7] + $n[9] + $n[11]) * 3 + $n[0] + $n[2] + $n[4] + $n[6] + $n[8] + $n[10]) % 10;
    $a = $a == 0 ? 0 : 10 - $a;
    return $n . $a;
}

$lang = $_GET["lang"];
$bname = $_GET["bname"];
$brand = $_POST["brand"];
$ProductType = $_POST["ProductType"];
$manufacturer = $_POST["manufacturer"];
$recommended = $_POST["recommended"];
$user_name = $_SESSION["managername"];

if ($_SESSION["thetype"] == "管理员" || $_SESSION["thetype"] == "超级管理员") {
    $sql = "select * from ph_" . $lang . " where 1=1";
} else {
    $sql = "select * from ph_" . $lang . " where 1=1 and user_name='" . $_SESSION["managername"] . "'";
}
if ($bname !== '' && isset($bname)) {
    $sql .= " and bname ='" . $bname . "'";
}
$result = mysql_query($sql);

require '../PHPExcel/PHPExcel.php';
require '../PHPExcel/PHPExcel/Writer/Excel2007.php';
//创建一个excel
$objPHPExcel = new PHPExcel();

$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);

//设置当前的sheet
$objPHPExcel->setActiveSheetIndex(0);
//设置sheet的name,excel文件名
$fileName = $bname . "-" . date('Ymdhis', time());

//表头
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'TemplateType=fptcustom');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Version=2018.0727');
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'TemplateSignature=S0lUQ0hFTg==');
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'The top 3 rows are for Amazon.com use only. Do not');
$objPHPExcel->getActiveSheet()->mergeCells('D1:E1');
$objPHPExcel->getActiveSheet()->setCellValue('K1', 'Images');
$objPHPExcel->getActiveSheet()->setCellValue('T1', 'Variation');
$objPHPExcel->getActiveSheet()->setCellValue('X1', 'Basic');
$objPHPExcel->getActiveSheet()->setCellValue('AD1', 'Discovery');
$objPHPExcel->getActiveSheet()->setCellValue('AU1', 'Product Enrichment');
$objPHPExcel->getActiveSheet()->setCellValue('BC1', 'Dimensions');
$objPHPExcel->getActiveSheet()->setCellValue('CB1', 'Fulfillment');
$objPHPExcel->getActiveSheet()->setCellValue('CI1', 'Compliance');
$objPHPExcel->getActiveSheet()->setCellValue('ED1', 'Offer');
$objPHPExcel->getActiveSheet()->setCellValue('FC1', 'b2b');
$objPHPExcel->getActiveSheet()->setCellValue('BC1', 'Dimensions');
$objPHPExcel->getActiveSheet()->setCellValue('BC1', 'Dimensions');
$objPHPExcel->getActiveSheet()->setCellValue('BC1', 'Dimensions');
$objPHPExcel->getActiveSheet()->setCellValue('BC1', 'Dimensions');
$objPHPExcel->getActiveSheet()->setCellValue('BC1', 'Dimensions');
$objPHPExcel->getActiveSheet()->setCellValue('BC1', 'Dimensions');
$objPHPExcel->getActiveSheet()->setCellValue('BC1', 'Dimensions');


$objPHPExcel->getActiveSheet()->getStyle('A1:FQ1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);

$headinfo1 = array(
    'Product Type',
    'Seller SKU',
    'Brand Name',
    'Product Name',
    'Manufacturer',
    'Recommended Browse Nodes',
    'Standard Price',
    'Quantity',
    'Merchant Shipping Group',
    'Main Image URL',
    'Swatch Image URL',
    'Other Image Url',
    'Other Image Url',
    'Other Image Url',
    'Other Image Url',
    'Other Image Url',
    'Other Image Url',
    'Other Image Url',
    'Other Image Url',
    'Parentage',
    'Parent SKU',
    'Relationship Type',
    'Variation Theme',
    'Update Delete',
    'GTIN Exemption Reason',
    'Product ID',
    'Product ID Type',
    'Manufacturer Part Number',
    'Product Description',
    'Merchant Catalogue Number',
    'Key Product Features',
    'Key Product Features',
    'Key Product Features',
    'Key Product Features',
    'Key Product Features',
    'Search Terms',
    'Search Terms',
    'Search Terms',
    'Search Terms',
    'Search Terms',
    'Platinum Keyword',
    'Platinum Keyword',
    'Platinum Keyword',
    'Platinum Keyword',
    'Platinum Keyword',
    'Home & Furniture Target Audience',
    'size_map',
    'length_range',
    'width_range',
    'Scent',
    'Colour',
    'Color Map',
    'Size',
    'Material Type',
    'Item Width Unit Of Measure',
    'item_width',
    'item_height',
    'Item Height Unit Of Measure',
    'Item Dimensions Unit Of Measure',
    'Item Length Unit Of Measure',
    'item_length',
    'Display Depth',
    'Item Display Depth Unit Of Measure',
    'Shipping Weight',
    'Website Shipping Weight Unit Of Measure',
    'Vacuum Sealer Bag Length',
    'Item Display Length Unit Of Measure',
    'Display Width',
    'Item Display Width Unit Of Measure',
    'Display Height',
    'Item Display Height Unit Of Measure',
    'Display Diameter',
    'Item Display Diameter Unit Of Measure',
    'Vacuum & Floor Care Item Weight',
    'Item Display Weight Unit Of Measure',
    'Volume',
    'Volume Capacity Name Unit Of Measure',
    'Volume Capacity of the appliance',
    'Item Display Volume Unit Of Measure',
    'Package Weight Unit Of Measure',
    'Package Dimensions Unit Of Measure',
    'package_weight',
    'Package Length',
    'Package Width',
    'Package Height',
    'Fulfillment Centre ID',
    'specific_uses_for_product1',
    'specific_uses_for_product2',
    'specific_uses_for_product3',
    'specific_uses_for_product4',
    'specific_uses_for_product5',
    'Product fiche',
    'Energy efficiency label',
    'legal_disclaimer_description',
    'safety_warning',
    'fedas_id',
    'EU Toys Safety Directive Age-Specific Warning',
    'EU Toys Safety Directive Non-Age-Specific Warning',
    'EU Toys Safety Directive Language Warning',
    'Country/Region of declaration',
    'Batteries are Included',
    'Is this product a battery or does it utilise batte',
    'Battery type/size',
    'Battery type/size',
    'Battery type/size',
    'Number of batteries',
    'Number of batteries',
    'Number of batteries',
    'Battery composition',
    'Battery weight (grams)',
    'battery_weight_unit_of_measure',
    'Number of Lithium Metal Cells',
    'Number of Lithium-ion Cells',
    'Lithium Battery Packaging',
    'Watt hours per battery',
    'lithium_battery_energy_content_unit_of_measure',
    'Lithium content (grams)',
    'lithium_battery_weight_unit_of_measure',
    'Applicable Dangerous Goods Regulations',
    'Applicable Dangerous Goods Regulations',
    'Applicable Dangerous Goods Regulations',
    'Applicable Dangerous Goods Regulations',
    'Applicable Dangerous Goods Regulations',
    'UN number',
    'Safety Data Sheet (SDS) URL',
    'Item Weight',
    'item_weight_unit_of_measure',
    'Volume',
    'item_volume_unit_of_measure',
    'Flash point (°C)?',
    'Categorization/GHS pictograms (select all that app',
    'Categorization/GHS pictograms (select all that app',
    'Categorization/GHS pictograms (select all that app',
    'Recommended Retail Price',
    'weee_tax_value',
    'Number of Items',
    'weee_tax_value_unit_of_measure',
    'Stop Selling Date',
    'Max Order Quantity',
    'Offering Release Date',
    'Scheduled Delivery SKU List',
    'Launch Date',
    'Currency',
    'Package Quantity',
    'Product Tax Code',
    'Release Date',
    'Sale Price',
    'Sale From Date',
    'Sale End Date',
    'Item Condition',
    'Offer Condition Note',
    'Handling Time',
    'Restock Date',
    'Maximum Aggregate Ship Quantity',
    'Can Be Gift Messaged',
    'Is Gift Wrap Available?',
    'Is Discontinued by Manufacturer',
    'Registered Parameter',
    'Business Price',
    'Quantity Price Type',
    'Quantity Lower Bound 1',
    'Quantity Price 1',
    'Quantity Lower Bound 2',
    'Quantity Price 2',
    'Quantity Lower Bound 3',
    'Quantity Price 3',
    'Quantity Lower Bound 4',
    'Quantity Price 4',
    'Quantity Lower Bound 5',
    'Quantity Price 5',
    'National Stock Number',
    'United Nations Standard Products and Services Code',
    'Pricing Action',
);

//设置指定单元格宽度
for ($i = 0; $i < count($headinfo1); $i++) {
    $objPHPExcel->getActiveSheet()->getColumnDimension(IntToChr($i))->setWidth(30);
}

//设置起始位置生成表格
$startX = 'A';
$startY = '2';
for ($i = 0; $i < count($headinfo1); $i++) {
    //水平居中
    $objPHPExcel->getActiveSheet()->getStyle($startX . $startY)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    //垂直居中
    $objPHPExcel->getActiveSheet()->getStyle($startX . $startY)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
    $objPHPExcel->getActiveSheet()->setCellValue($startX++ . $startY, $headinfo1[$i]);
    //设置单元格属性(文本属性)
    $objPHPExcel->getActiveSheet()->getStyle($startX . $startY)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
}

$headinfo2 = array(
    'feed_product_type',
    'item_sku',
    'brand_name',
    'item_name',
    'manufacturer',
    'recommended_browse_nodes',
    'standard_price',
    'quantity',
    'merchant_shipping_group_name',
    'main_image_url',
    'swatch_image_url',
    'other_image_url1',
    'other_image_url2',
    'other_image_url3',
    'other_image_url4',
    'other_image_url5',
    'other_image_url6',
    'other_image_url7',
    'other_image_url8',
    'parent_child',
    'parent_sku',
    'relationship_type',
    'variation_theme',
    'update_delete',
    'gtin_exemption_reason',
    'external_product_id',
    'external_product_id_type',
    'part_number',
    'product_description',
    'catalog_number',
    'bullet_point1',
    'bullet_point2',
    'bullet_point3',
    'bullet_point4',
    'bullet_point5',
    'generic_keywords1',
    'generic_keywords2',
    'generic_keywords3',
    'generic_keywords4',
    'generic_keywords5',
    'platinum_keywords1',
    'platinum_keywords2',
    'platinum_keywords3',
    'platinum_keywords4',
    'platinum_keywords5',
    'target_audience_keywords',
    'size_map',
    'length_range',
    'width_range',
    'scent_name',
    'color_name',
    'color_map',
    'size_name',
    'material_type',
    'item_width_unit_of_measure',
    'item_width',
    'item_height',
    'item_height_unit_of_measure',
    'item_dimensions_unit_of_measure',
    'item_length_unit_of_measure',
    'item_length',
    'item_display_depth',
    'item_display_depth_unit_of_measure',
    'website_shipping_weight',
    'website_shipping_weight_unit_of_measure',
    'item_display_length',
    'item_display_length_unit_of_measure',
    'item_display_width',
    'item_display_width_unit_of_measure',
    'item_display_height',
    'item_display_height_unit_of_measure',
    'item_display_diameter',
    'item_display_diameter_unit_of_measure',
    'item_display_weight',
    'item_display_weight_unit_of_measure',
    'volume_capacity_name',
    'volume_capacity_name_unit_of_measure',
    'item_display_volume',
    'item_display_volume_unit_of_measure',
    'package_weight_unit_of_measure',
    'package_dimensions_unit_of_measure',
    'package_weight',
    'package_length',
    'package_width',
    'package_height',
    'fulfillment_center_id',
    'specific_uses_for_product1',
    'specific_uses_for_product2',
    'specific_uses_for_product3',
    'specific_uses_for_product4',
    'specific_uses_for_product5',
    'product_efficiency_image_url',
    'energy_efficiency_image_url',
    'legal_disclaimer_description',
    'safety_warning',
    'fedas_id',
    'eu_toys_safety_directive_age_warning',
    'eu_toys_safety_directive_warning',
    'eu_toys_safety_directive_language',
    'country_string',
    'are_batteries_included',
    'batteries_required',
    'battery_type1',
    'battery_type2',
    'battery_type3',
    'number_of_batteries1',
    'number_of_batteries2',
    'number_of_batteries3',
    'battery_cell_composition',
    'battery_weight',
    'battery_weight_unit_of_measure',
    'number_of_lithium_metal_cells',
    'number_of_lithium_ion_cells',
    'lithium_battery_packaging',
    'lithium_battery_energy_content',
    'lithium_battery_energy_content_unit_of_measure',
    'lithium_battery_weight',
    'lithium_battery_weight_unit_of_measure',
    'supplier_declared_dg_hz_regulation1',
    'supplier_declared_dg_hz_regulation2',
    'supplier_declared_dg_hz_regulation3',
    'supplier_declared_dg_hz_regulation4',
    'supplier_declared_dg_hz_regulation5',
    'hazmat_united_nations_regulatory_id',
    'safety_data_sheet_url',
    'item_weight',
    'item_weight_unit_of_measure',
    'item_volume',
    'item_volume_unit_of_measure',
    'flash_point',
    'ghs_classification_class1',
    'ghs_classification_class2',
    'ghs_classification_class3',
    'list_price',
    'weee_tax_value',
    'number_of_items',
    'weee_tax_value_unit_of_measure',
    'offering_end_date',
    'max_order_quantity',
    'offering_start_date',
    'delivery_schedule_group_id',
    'product_site_launch_date',
    'currency',
    'item_package_quantity',
    'product_tax_code',
    'merchant_release_date',
    'sale_price',
    'sale_from_date',
    'sale_end_date',
    'condition_type',
    'condition_note',
    'fulfillment_latency',
    'restock_date',
    'max_aggregate_ship_quantity',
    'offering_can_be_gift_messaged',
    'offering_can_be_giftwrapped',
    'is_discontinued_by_manufacturer',
    'missing_keyset_reason',
    'business_price',
    'quantity_price_type',
    'quantity_lower_bound1',
    'quantity_price1',
    'quantity_lower_bound2',
    'quantity_price2',
    'quantity_lower_bound3',
    'quantity_price3',
    'quantity_lower_bound4',
    'quantity_price4',
    'quantity_lower_bound5',
    'quantity_price5',
    'national_stock_number',
    'unspsc_code',
    'pricing_action',
);

$startX = 'A';
$startY = '3';
for ($i = 0; $i < count($headinfo2); $i++) {
    //水平居中
    $objPHPExcel->getActiveSheet()->getStyle($startX . $startY)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    //垂直居中
    $objPHPExcel->getActiveSheet()->getStyle($startX . $startY)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
    $objPHPExcel->getActiveSheet()->setCellValue($startX++ . $startY, $headinfo2[$i]);
    //设置单元格属性(文本属性)
    $objPHPExcel->getActiveSheet()->getStyle($startX . $startY)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
}

$mun = 3;
while ($row = mysql_fetch_array($result)) {
    $key1 = "";
    $key2 = "";
    $key3 = "";
    $key4 = "";
    $key5 = "";
    $img1 = "";
    $img2 = "";
    $img3 = "";
    $img4 = "";
    $img5 = "";
    $img6 = "";
    $img7 = "";
    $img8 = "";
    $img9 = "";
    $mun++;
    if (!empty($row['keywords'])) {
        $key = explode("\r\n", $row['keywords']);
        if (!empty($key[0])) {
            $key1 = $key[0];
        }
        if (!empty($key[1])) {
            $key2 = $key[1];
        }
        if (!empty($key[2])) {
            $key3 = $key[2];
        }
        if (!empty($key[3])) {
            $key4 = $key[3];
        }
        if (!empty($key[4])) {
            $key5 = $key[4];
        }
    }

    $sqla = "select * from ph_img where proid='" . $row['ID'] . "' and btid is null order by px asc";
    $resulta = mysql_query($sqla);
    while ($rowa = mysql_fetch_array($resulta)) {
        if (!empty($rowa['imgpath'])) {
            $img1 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowa['imgpath'];
        } else {
            $img1 = "";
        }
        $rowa = mysql_fetch_array($resulta);
        if (!empty($rowa['imgpath'])) {
            $img2 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowa['imgpath'];
        } else {
            $img2 = "";
        }
        $rowa = mysql_fetch_array($resulta);
        if (!empty($rowa['imgpath'])) {
            $img3 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowa['imgpath'];
        } else {
            $img3 = "";
        }
        $rowa = mysql_fetch_array($resulta);
        if (!empty($rowa['imgpath'])) {
            $img4 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowa['imgpath'];
        } else {
            $img4 = "";
        }
        $rowa = mysql_fetch_array($resulta);
        if (!empty($rowa['imgpath'])) {
            $img5 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowa['imgpath'];
        } else {
            $img5 = "";
        }
        $rowa = mysql_fetch_array($resulta);
        if (!empty($rowa['imgpath'])) {
            $img6 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowa['imgpath'];
        } else {
            $img6 = "";
        }
        $rowa = mysql_fetch_array($resulta);
        if (!empty($rowa['imgpath'])) {
            $img7 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowa['imgpath'];
        } else {
            $img7 = "";
        }
        $rowa = mysql_fetch_array($resulta);
        if (!empty($rowa['imgpath'])) {
            $img8 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowa['imgpath'];
        } else {
            $img8 = "";
        }
        $rowa = mysql_fetch_array($resulta);
        if (!empty($rowa['imgpath'])) {
            $img9 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowa['imgpath'];
        } else {
            $img9 = "";
        }
    }
    $rowa = null;
    unset($rowa);
    $spliter = "<br/>";
    //$content = str_replace("\r\n", $spliter, $row['content']);
//    $content = htmlentities($content);
    $content = handContent($row['content']);
    $sqls = "select * from ph_shuxing where proid='" . $row['ID'] . "' order by ID asc";
	if (mysql_num_rows($results) < 1) {
    $results = mysql_query($sqls);
    $sku = $row['skucode'];
    $content = replacebd($content, $brand);
    if (strpos($row['des'], $spliter) !== false) {
        $des = explode($spliter, $row['des']);
    } else {
        $des = explode("\r\n", $row['des']);
    }
    $des1 = $des[0];
    $des2 = $des[1];
    $des3 = $des[2];
    $des4 = $des[3];
    $des5 = $des[4];

//    $objPHPExcel->getActiveSheet()->getStyle('AC' . $mun)->getAlignment()->setWrapText(true);

    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $mun, $ProductType);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B' . $mun, $sku);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('C' . $mun, $brand);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('D' . $mun, $row['proname']);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('E' . $mun, $manufacturer);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('F' . $mun, $recommended);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('G' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('H' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('I' . $mun, 'Migrated Template');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('J' . $mun, $img1);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('K' . $mun, $img1);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('L' . $mun, $img2);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('M' . $mun, $img3);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('N' . $mun, $img4);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('O' . $mun, $img5);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('P' . $mun, $img6);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('Q' . $mun, $img7);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('R' . $mun, $img8);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('S' . $mun, $img9);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('T' . $mun, 'parent');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('U' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('V' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('W' . $mun, $row['btname']);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('X' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('Y' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('Z' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AA' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AB' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AC' . $mun, $content);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AD' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AE' . $mun, $des1);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AF' . $mun, $des2);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AG' . $mun, $des3);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AH' . $mun, $des4);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AI' . $mun, $des5);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AJ' . $mun, $key1);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AK' . $mun, $key2);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AL' . $mun, $key3);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AM' . $mun, $key4);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AN' . $mun, $key5);
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AO' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AP' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AQ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AR' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AS' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AT' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AU' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AV' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AW' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AX' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AY' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AZ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BA' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BB' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BC' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BD' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BE' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BF' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BG' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BH' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BI' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BJ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BK' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BL' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BM' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BN' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BO' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BP' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BQ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BR' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BS' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BT' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BU' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BV' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BW' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BX' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BY' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BZ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CA' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CB' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CC' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CD' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CE' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CF' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CG' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CH' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CI' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CJ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CK' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CL' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CM' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CN' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CO' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CP' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CQ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CR' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CS' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CT' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CU' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CV' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CW' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CX' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CY' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CZ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DA' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DB' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DC' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DD' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DE' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DF' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DG' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DH' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DI' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DJ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DK' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DL' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DM' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DN' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DO' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DP' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DQ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DR' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DS' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DT' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DU' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DV' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DW' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DX' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DY' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DZ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EA' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EB' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EC' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('ED' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EE' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EF' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EG' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EH' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EI' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EJ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EK' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EL' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EM' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EN' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EO' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EP' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EQ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('ER' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('ES' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('ET' . $mun, 'New');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EU' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EV' . $mun, '10');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EW' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EX' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EY' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EZ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FA' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FB' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FC' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FD' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FE' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FF' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FG' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FH' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FI' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FJ' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FK' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FL' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FM' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FN' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FO' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FP' . $mun, '');
    $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FQ' . $mun, '');

    if (mysql_num_rows($results) < 1) {
        $mun++;
//        $objPHPExcel->getActiveSheet()->getStyle('AC' . $mun)->getAlignment()->setWrapText(true);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $mun, $ProductType);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B' . $mun, $sku.'-1');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('C' . $mun, $brand);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('D' . $mun, $row['proname']);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('E' . $mun, $manufacturer);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('F' . $mun, $recommended);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('G' . $mun, $row['saleprice']);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('H' . $mun, $row['kucun']);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('I' . $mun, 'Migrated Template');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('J' . $mun, $img1);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('K' . $mun, $img1);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('L' . $mun, $img2);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('M' . $mun, $img3);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('N' . $mun, $img4);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('O' . $mun, $img5);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('P' . $mun, $img6);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('Q' . $mun, $img7);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('R' . $mun, $img8);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('S' . $mun, $img9);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('T' . $mun, 'child');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('U' . $mun, $sku);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('V' . $mun, 'Variation');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('W' . $mun, $row['btname']);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('X' . $mun, 'update');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('Y' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('Z' . $mun, EAN13(randomkeys(12)));
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AA' . $mun, 'EAN');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AB' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AC' . $mun, $content);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AD' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AE' . $mun, $des1);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AF' . $mun, $des2);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AG' . $mun, $des3);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AH' . $mun, $des4);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AI' . $mun, $des5);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AJ' . $mun, $key1);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AK' . $mun, $key2);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AL' . $mun, $key3);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AM' . $mun, $key4);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AN' . $mun, $key5);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AO' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AP' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AQ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AR' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AS' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AT' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AU' . $mun, 'One size');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AV' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AW' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AX' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AY' . $mun, 'color');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AZ' . $mun, 'color');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BA' . $mun, 'One size');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BB' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BC' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BD' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BE' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BF' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BG' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BH' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BI' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BJ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BK' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BL' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BM' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BN' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BO' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BP' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BQ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BR' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BS' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BT' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BU' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BV' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BW' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BX' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BY' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BZ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CA' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CB' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CC' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CD' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CE' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CF' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CG' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CH' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CI' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CJ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CK' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CL' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CM' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CN' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CO' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CP' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CQ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CR' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CS' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CT' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CU' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CV' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CW' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CX' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CY' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CZ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DA' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DB' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DC' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DD' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DE' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DF' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DG' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DH' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DI' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DJ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DK' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DL' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DM' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DN' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DO' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DP' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DQ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DR' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DS' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DT' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DU' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DV' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DW' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DX' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DY' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DZ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EA' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EB' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EC' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('ED' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EE' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EF' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EG' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EH' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EI' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EJ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EK' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EL' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EM' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EN' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EO' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EP' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EQ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('ER' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('ES' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('ET' . $mun, 'New');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EU' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EV' . $mun, '10');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EW' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EX' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EY' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EZ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FA' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FB' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FC' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FD' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FE' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FF' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FG' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FH' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FI' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FJ' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FK' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FL' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FM' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FN' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FO' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FP' . $mun, '');
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FQ' . $mun, '');
    } else {
        $i = 0;
        while ($rows = mysql_fetch_array($results)) {
            $btimg1 = "";
            $btimg2 = "";
            $btimg3 = "";
            $btimg4 = "";
            $btimg5 = "";
            $btimg6 = "";
            $btimg7 = "";
            $btimg8 = "";
            $btimg9 = "";
            $i = $i + 1;
            $mun++;
            if (strpos($rows['cname'], ",") !== false) {
                $cname = explode(",", $rows['cname']);
                $cname1 = $cname[0];
                $cname2 = $cname[1];
            } else {
                $cname1 = $rows['cname'];
                $cname2 = "";
            }
            $sqlb = "select * from ph_img where btid='" . $rows['ID'] . "'";
            $resultb = mysql_query($sqlb);
            while ($rowb = mysql_fetch_array($resultb)) {

                if (!empty($rowb['imgpath'])) {
                    $btimg1 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowb['imgpath'];
                } else {
                    $btimg1 = $img1;
                }
                $rowb = mysql_fetch_array($resultb);
                if (!empty($rowb['imgpath'])) {
                    $btimg2 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowb['imgpath'];
                } else {
                    $btimg2 = $img2;
                }
                $rowb = mysql_fetch_array($resultb);
                if (!empty($rowb['imgpath'])) {
                    $btimg3 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowb['imgpath'];
                } else {
                    $btimg3 = $img3;
                }
                $rowb = mysql_fetch_array($resultb);
                if (!empty($rowb['imgpath'])) {
                    $btimg4 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowb['imgpath'];
                } else {
                    $btimg4 = $img4;
                }
                $rowb = mysql_fetch_array($resultb);
                if (!empty($rowb['imgpath'])) {
                    $btimg5 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowb['imgpath'];
                } else {
                    $btimg5 = $img5;
                }
                $rowb = mysql_fetch_array($resultb);
                if (!empty($rowb['imgpath'])) {
                    $btimg6 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowb['imgpath'];
                } else {
                    $btimg6 = $img6;
                }
                $rowb = mysql_fetch_array($resultb);
                if (!empty($rowb['imgpath'])) {
                    $btimg7 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowb['imgpath'];
                } else {
                    $btimg7 = $img7;
                }
                $rowb = mysql_fetch_array($resultb);
                if (!empty($rowb['imgpath'])) {
                    $btimg8 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowb['imgpath'];
                } else {
                    $btimg8 = $img8;
                }
                $rowb = mysql_fetch_array($resultb);
                if (!empty($rowb['imgpath'])) {
                    $btimg9 = "http://" . $_SERVER['SERVER_NAME'] . "/products/" . $rowb['imgpath'];
                } else {
                    $btimg9 = $img9;
                }
            }

//            $objPHPExcel->getActiveSheet()->getStyle('AC' . $mun)->getAlignment()->setWrapText(true);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $mun, $ProductType);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('B' . $mun, $sku.'-'.$i);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('C' . $mun, $brand);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('D' . $mun, $row['proname'] . "," . $rows['cname']);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('E' . $mun, $manufacturer);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('F' . $mun, $recommended);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('G' . $mun, $rows['saleprice']);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('H' . $mun, $rows['kucun']);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('I' . $mun, 'Migrated Template');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('J' . $mun, $btimg1);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('K' . $mun, $btimg1);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('L' . $mun, $btimg2);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('M' . $mun, $btimg3);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('N' . $mun, $btimg4);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('O' . $mun, $btimg5);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('P' . $mun, $btimg6);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('Q' . $mun, $btimg7);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('R' . $mun, $btimg8);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('S' . $mun, $btimg9);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('T' . $mun, 'child');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('U' . $mun, $sku);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('V' . $mun, 'Variation');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('W' . $mun, $row['btname']);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('X' . $mun, 'update');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('Y' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('Z' . $mun, EAN13(randomkeys(12)));
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AA' . $mun, 'EAN');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AB' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AC' . $mun, $content);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AD' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AE' . $mun, $des1);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AF' . $mun, $des2);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AG' . $mun, $des3);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AH' . $mun, $des4);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AI' . $mun, $des5);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AJ' . $mun, $key1);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AK' . $mun, $key2);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AL' . $mun, $key3);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AM' . $mun, $key4);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AN' . $mun, $key5);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AO' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AP' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AQ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AR' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AS' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AT' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AU' . $mun, $cname2);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AV' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AW' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AX' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AY' . $mun, $cname1);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AZ' . $mun, $cname1);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BA' . $mun, $cname2);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BB' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BC' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BD' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BE' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BF' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BG' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BH' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BI' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BJ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BK' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BL' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BM' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BN' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BO' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BP' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BQ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BR' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BS' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BT' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BU' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BV' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BW' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BX' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BY' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('BZ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CA' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CB' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CC' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CD' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CE' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CF' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CG' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CH' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CI' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CJ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CK' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CL' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CM' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CN' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CO' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CP' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CQ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CR' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CS' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CT' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CU' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CV' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CW' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CX' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CY' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('CZ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DA' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DB' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DC' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DD' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DE' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DF' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DG' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DH' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DI' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DJ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DK' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DL' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DM' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DN' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DO' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DP' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DQ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DR' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DS' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DT' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DU' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DV' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DW' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DX' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DY' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('DZ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EA' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EB' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EC' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('ED' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EE' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EF' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EG' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EH' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EI' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EJ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EK' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EL' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EM' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EN' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EO' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EP' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EQ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('ER' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('ES' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('ET' . $mun, 'New');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EU' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EV' . $mun, '10');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EW' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EX' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EY' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('EZ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FA' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FB' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FC' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FD' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FE' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FF' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FG' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FH' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FI' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FJ' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FK' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FL' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FM' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FN' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FO' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FP' . $mun, '');
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue('FQ' . $mun, '');
        }
    }
}

/*
 * Job:导出无数据空白页面问题修改
 * 下面代码从IF中拿到外面
 */
ob_end_clean();
header("Pragma: public");
header("Expires: 0");
header('Cache-Control: max-age=0'); //禁止缓存
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
header("Content-Type:application/force-download");
header("Content-Type:application/vnd.ms-execl");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");
header('Content-Disposition:attachment;filename=' . $fileName . '.xls');
header("Content-Transfer-Encoding:binary");
$objWriter->save('php://output');


/**
 * 数字转字母 （类似于Excel列标）
 * @param Int $index 索引值
 * @param Int $start 字母起始值
 * @return String 返回字母
 */
function IntToChr($index, $start = 65)
{
    $str = '';
    if (floor($index / 26) > 0) {
        $str .= IntToChr(floor($index / 26) - 1);
    }
    return $str . chr($index % 26 + $start);
}

/**
 * 处理字符串中多个连续br替换一个
 */
function handContent($str = ''){
    $arr = array_filter(explode("<br/>",$str));
    return implode("<br/>",$arr);
}

?>
